package cn.wh.ymcc.mq;


import cn.wh.ymcc.feignclients.CommonFeignClient;
import cn.wh.ymcc.result.JSONResult;
import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.nio.charset.StandardCharsets;

@Component
@RocketMQMessageListener(
        consumerGroup="medis-consumer-group",
        topic="media-topic",
        selectorExpression="media-tags"
)

public class MediaFIleConsumer implements RocketMQListener<MessageExt> {

    @Autowired
    private CommonFeignClient commonFeignClient;

    @Override
    public void onMessage(MessageExt messageExt) {
        System.out.println("消费成功");
        String courseName = new String(messageExt.getBody(), StandardCharsets.UTF_8);
        JSONResult jsonResult = commonFeignClient.messagePush(courseName);
        System.out.println(jsonResult.getMessage());

    }
}